<template>
  <div class="detail">
    <el-card>
      <el-tabs>
        <el-tab-pane label="登陆账户设置">
          <el-form ref="form" :model="form" :rules="rules" label-width="100px">
            <el-form-item label="姓名" prop="username">
              <el-input v-model="form.username" />
            </el-form-item>

            <el-form-item label="密码" prop="password">
              <el-input v-model="form.password" type="password" />
            </el-form-item>

            <el-form-item>
              <el-button type="primary" @click="submit">更新</el-button>
              <el-button>取消</el-button>
            </el-form-item>
          </el-form>
        </el-tab-pane>
        <el-tab-pane label="个人详情">个人详情</el-tab-pane>
        <el-tab-pane label="岗位信息">岗位信息</el-tab-pane>
      </el-tabs>
    </el-card>
  </div>
</template>

<script>
import { sysUser } from '@/api/human'
export default {
  data() {
    return {
      id: this.$route.params.id,
      form: {
        username: '',
        password: ''
      },
      rules: {
        username: [{ required: true, message: true, trigger: 'change' }],
        password: [
          { required: true, message: true, trigger: 'change' },
          { min: 6, max: 12, message: '请输入6-12位密码', trigger: 'change' }
        ]
      }
    }
  },
  created() {
    this.getData()
  },
  methods: {
    submit() {
      this.$refs.form.validate((result) => {
        if (result) {
          this.$message.success('验证成功')
        }
      })
    },

    async getData() {
      const res = await sysUser(this.id)
      console.log('获取用户信息', res)
      this.userInfo = res.data
      this.form.username = res.data.username
    }
  }
}
</script>

<style lang="scss" scoped>
.detail {
  padding: 20px;
}
</style>
